<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商品详情</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
<meta name="format-detection" content="telephone=no, email=no" />
<link rel="stylesheet" href="{{ url('/common/mobile-common/common.css') }}">
<link rel="stylesheet" href="{{ url('/mobile/css/banner.css') }}">
<link rel="stylesheet" href="{{ url('/mobile/css/header.css') }}">		
<link rel="stylesheet" href="{{ url('/mobile/css/goods/goodsdetail.css') }}">	
<script src="{{ url('mobile/js/jquery-1.8.3.min.js')}}"></script>
<script src="{{ url('mobile/js/swiper/idangerous.swiper.min.js') }}"></script>
<link rel="stylesheet" href="{{ url('/') }}/layer/skin/layer.css" />
<script src="{{ url('/') }}/layer/layer.js"></script>
<script src="{{ url('/common/mobile-common/hmt.js') }}"></script>
</head>
<body>
	<div class="abouts">
		<div class="wrap-cont clearfix">

					<!--图片展示-->
					<div class="device">
					  	<div class="swiper-container clearfix">
						    <div class="swiper-wrapper clearfix">
								@foreach($pics as $v)
						      	<div class="swiper-slide"> 
						      		<img src="{{ config('config.picHostPrefix').$v->middle_img }}">
						      	</div>
								@endforeach
						    </div>
					  	</div>
						<div class="pagination1"></div>
					</div>
				</div>
					<!--景点信息-->
					<div class="wrap-cont jdxx">
						<div class="scener-info">
							<p class="p-tit">
								<span>{{$one->name}}</span>
							</p>
							<p class="jg">
								<?php if(empty($memberId)) {?>
								<span>
									@if(!empty($one->discount)&&$one->discount!=0)
									¥ <i>{{$one->price*$one->discount}}</i>
									@else
									¥ <i>{{$one->price}}</i>
									@endif
								</span>
								<?php } else {
									$memberVip = DB::table('members')->where('id',$memberId)->first();
									if (!empty($one->vip_price)&&$memberVip->vip==1) {
									?>
										<span>
											@if(!empty($one->discount)&&$one->discount!=0)
												¥ {{$one->vip_price*$one->discount}}<em>绑卡会员专享价</em>
											@else
												¥ {{$one->vip_price}}<em>绑卡会员专享价</em>
											@endif
										</span>
										<span>
											<i class="yjg">¥{{$one->price}}</i>
										</span>
									<?php } else {?>
										<span>
											@if(!empty($one->discount)&&$one->discount!=0)
												¥ <i>{{$one->price*$one->discount}}</i>
											@else
												¥ <i>{{$one->price}}</i>
											@endif
										</span>
								<?php }}?>

								@if($one->discount&&$one->discount!=0)
								<em>{{$one->discount*10}}折</em>
								<i class="yj">{{$one->price}}</i>
								@endif
							</p>
							@if(($one->discount&&$one->discount!=0)||$derate||$give)
							<p class="hd">
								<label>活动</label>
								<a>
									@if($one->discount&&$one->discount!=0)
									<span><i>打折</i><em>{{$one->discount*10}}折</em></span>
									@endif
									@if($derate)
									<span><i>满减</i><em>@foreach($derate as $v)满{{$v->effect_amount}}减{{$v->cheap_amount}}&nbsp @endforeach</em></span>
									@endif
									@if($give)
									<span><i>满送</i><em>@foreach($give as $v)满{{$v->effect_amount}}送电子卡{{$v->num}}张 &nbsp @endforeach</em></span>
									@endif
								</a>
							</p>
							@endif
							<p class="yf">
								<label>运费:</label>
								<span>北京&nbsp;至</span>
								<span>全国
									<!--<select>
										<option>上海</option>
										<option>南京</option>
										<option>山西</option>
									</select>-->
								</span>
								@if(empty($one->fname))
								<i>免运费</i>
								@endif
							</p>
							<p class="zf">
								<label>支付:</label>
								<span class="zfb">微信支付</span>
							</p>
							<p>
								<label>商品类型:</label>
								<span>{{$one->category}}</span>
							</p>
							@if(!empty($estime))
							<p>
								<label>有效期:</label>
								<span> {{App\Http\Util\TimeHelper::formatDate($one->estime)}} 至 {{App\Http\Util\TimeHelper::formatDate($one->eetime)}}</span>
							</p>
							@endif
							<p class="sl">
								<label>购买数量:</label>
								<span class="reduces" id="reduce">-</span>
								<input type="text" value="1" class="buyNum" id="buyNum">
								<span class="adds" id="add">+</span>
								<i class="xz-num">单次最多购买{{$one->limit_num}}件</i>
								@if(!empty($one->inventory))
									<em class="kcl">（有货）</em>
								@else
									<em class="kcl">（无货）</em>
								@endif
							</p>
					</div>
					<div class="scener-js">
						<h3>商品详情</h3>
						<div class="js-txt">
							{!! html_entity_decode($one->description) !!}
						</div>
					</div>
					<div class="buy-now">
						<a class="addCart">加入购物车</a>
						<a class="qjs" data-id="{{$one->id}}">立即购买</a>
					</div>
				</div>
				
		</div>
	</div>
	
</body>
<script>
	$(function(){
		//图片展示
		var mySwiper = new Swiper('.swiper-container',{
			pagination: '.pagination1',
			loop:true,
			grabCursor: true,
			paginationClickable: true,
			autoplay:3000,
				speed:500,
		});
		 //购买数量增加减少
       var t=$("#buyNum");
		t.keyup(function (event) {
				if (event.keyCode != 8) {
					if (isNaN($(this).val())|| parseInt($(this).val())<1) {
						alert("请输入正确的数值！");
						t.val(1);
						
					} else if(parseInt($(this).val())> "{{$one->limit_num}}"){
						alert('单次最多购买{{$one->limit_num}}件');
							t.val({{$one->limit_num}});
					}
					else {
						return t.val();
					}
				}
			});
			
    	$("#add").click(function(){
        		$("#reduce").css("cursor","pointer");
        		t.val(parseInt(t.val())+1);
				if(t.val()>=parseInt({{$one->limit_num}})){
				$("#add").css("cursor","not-allowed");
				$(".xz-num").show();
				$(".kcl").hide();
				t.val({{$one->limit_num}});
				$(".xz-num i").text(t.val());
			}
        });
        $("#reduce").click(function(){
        		$(".kcl").show();
        		$(".xz-num").hide();
    			$("#reduce").css("cursor","pointer"); 
				t.val(parseInt(t.val())-1);
        		if(t.val()<=1){
        		t.val(1);
        		$("#reduce").css("cursor","not-allowed");
    		} 
        	       	
        });
		//立即购买
		$(".qjs").click(function(){
			var goodId = $(this).data('id');
			var num = $("#buyNum").val();
			$.post("{{ url('wap/order/inputOrder')}}",{goodId:goodId,num:num},function(data){
				if(data.success){
					window.location.href="{{url('wap/order/commit')}}";
				}else{
					if (data.type==9) {
						window.location.href = "{{url('wap/member/mid')}}";
					} else if (data.type==1) {
						layer.alert(data.msg)
						window.location.href="{{url('wap/receiver/add')}}";
					} else {
						layer.alert(data.msg);
					}
				}
			});
		})
		//加入购物车
		$('.addCart').click(function(){
			var num = $("#buyNum").val();
			$.ajax({
				type:'post',
				url:"{{ url('wap/cart/add') }}",
				data:{
					product_id:'{{$one->id}}',
					num:num,
				},
				success:function(data){
					if(data.success){
						alert("添加成功！");
					} else {
						if (data.type==9) {
							window.location.href = "{{url('wap/member/mid')}}";
						} else {
							layer.msg(data.msg);
						}
					}
				}
			});
		});
	})
		
</script>
</html>
